// ============================================================================
// Implementation file for Helper
//
// Solution for CPSC 4780 Fall 2010 Group Project
// Fei Wang
// April 8, 2011
//
// Handles the send and recive for both client and server socket
// ==========================================================================
#include"Helper.h"
#include "ServerSocket.h"
#include "ClientSocket.h"
#include "SocketException.h"
using namespace std;
// ==========================================================================
// function handle clientSocket receive - recive and reply an ack
//===========================================================================
void clntsock_receive(string & request , ClientSocket * Socket)
{       
  *Socket >> request;
  *Socket << "ack";
}
// ==========================================================================
// function handle clientSocket send - send and wait for an ack
//===========================================================================
void clntsock_send(string msg , ClientSocket * Socket)
{
  string ack = "";
  *Socket << msg;
  while(ack != "ack")
  {
    *Socket >> ack;
  }
}
// ==========================================================================
// function handle ServerSocket receive - recive and reply an ack
//===========================================================================
void svcsock_receive(string & request , ServerSocket * Socket)
{       
  *Socket >> request;
  *Socket << "ack";
}
// ==========================================================================
// function handle ServerSocket send - send and wait for an ack
//===========================================================================
void svcsock_send(string  msg , ServerSocket * Socket)
{;
  string ack = "";
  *Socket << msg;
  while(ack != "ack")
  {
    *Socket >> ack;
  }
}
